package io.renren.modules.dangan.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.dangan.entity.TNzyxmEntity;
import io.renren.modules.dangan.service.TNzyxmService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * ${comments}
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2019-12-08 19:00:46
 */
@RestController
@RequestMapping("dangan/tnzyxm")
@CrossOrigin
public class TNzyxmController {
    @Autowired
    private TNzyxmService tNzyxmService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("dangan:tnzyxm:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tNzyxmService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{xmGuid}")
    @RequiresPermissions("dangan:tnzyxm:info")
    public R info(@PathVariable("xmGuid") String xmGuid){
        TNzyxmEntity tNzyxm = tNzyxmService.getById(xmGuid);

        return R.ok().put("tNzyxm", tNzyxm);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("dangan:tnzyxm:save")
    public R save(@RequestBody TNzyxmEntity tNzyxm){
        tNzyxmService.save(tNzyxm);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("dangan:tnzyxm:update")
    public R update(@RequestBody TNzyxmEntity tNzyxm){
        ValidatorUtils.validateEntity(tNzyxm);
        tNzyxmService.updateById(tNzyxm);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("dangan:tnzyxm:delete")
    public R delete(@RequestBody String[] xmGuids){
        tNzyxmService.removeByIds(Arrays.asList(xmGuids));

        return R.ok();
    }

}
